import * as Cesium from 'cesium/Cesium'
import Measurement from "./Measurement";
import PolylineMeasurementDrawing from "./PolylineMeasurementDrawing";

function getIcon(e) {
    return '<svg viewBox="0 0 30 30" height="' + e + 'px" width="' + e + 'px">\n                  <g transform="translate(0,-267)">\n                   <circle cx="3.8532958" cy="293.99896" r="2.0788691" />\n                   <circle cx="7.2651663" cy="276.26389" r="2.0788691" />\n                   <circle cx="24.571842" cy="285.56577" r="2.0788691" />\n                   <circle cx="26.916754" cy="270.38345" r="2.0788691" />\n                   <path d="m 3.7523356,294.14823 3.602242,-17.81109 17.3608064,9.35582 2.401494,-15.00934" />\n                 </g>\n               </svg>'
}

function PolylineMeasurement(e) {
    e = Cesium. defaultValue(e,  Cesium.defaultValue.EMPTY_OBJECT),
        Measurement.call(this, e), this._drawing = new PolylineMeasurementDrawing(e)
}
PolylineMeasurement.prototype = Object.create(Measurement.prototype),
    PolylineMeasurement.prototype.constructor = PolylineMeasurement,
    Cesium.defineProperties(PolylineMeasurement.prototype, {
        distance: {
            get: function() {
                return this._drawing.distance
            }
        },
        icon: {
            value: getIcon(15)
        },
        thumbnail: {
            value: getIcon(25)
        },
        type: {
            value: "折线距离"
        },
        instructions: {
            value: ["单击以开始绘制多段线","继续单击以添加更多点","双击以完成绘制"]
        },
        id: {
            value: "polylineMeasurement"
        }
    }),
    PolylineMeasurement.prototype.handleDoubleClick = function() {
        this._drawing.handleDoubleClick()
    }
    ,
    PolylineMeasurement.prototype.handleClick = function(e) {
        this._drawing.handleClick(e)
    }
    ,
    PolylineMeasurement.prototype.handleMouseMove = function(e) {
        this._drawing.handleMouseMove(e)
    }
    ,
    PolylineMeasurement.prototype.reset = function() {
        this._drawing.reset()
    }
    ,
    PolylineMeasurement.prototype.isDestroyed = function() {
        return !1
    }
    ,
    PolylineMeasurement.prototype.destroy = function() {
        return this._drawing.destroy(),
            Cesium.destroyObject(this)
    }
;

export default PolylineMeasurement;